-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
V3.1 audit fixes #255
base: feat/v3.1
Are you sure you want to change the base?
V3.1 audit fixes #255
Conversation
Coverage SummaryTotals
FilesExpand
|
Contract comparison - from e3fed00 to 38538b9
|
bridge-proxy: refund refactor
The base branch was changed.
bridge-proxy/src/bridge-proxy.rs
Outdated
|
||
if call_data.endpoint.is_empty() | ||
let non_empty_args = call_data.args.is_some(); | ||
if (call_data.endpoint.is_empty() && non_empty_args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if i send empty endpoint and some arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then the if
statement would be executed and we would
self.finish_execute_gracefully(tx_id);
return;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrote an integration test for this. Apparently, if I send this RAW SC call data 000000000000000002faf08000
(empty function and 50 mil gas limit) it does not refund the transfer. Good catch @dragos-rebegea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed the condition to
if call_data.endpoint.is_empty()
self.finish_execute_gracefully(tx_id);
return;
Added unit test.
"gas": "*", | ||
"refund": "*" | ||
} | ||
}, | ||
{ | ||
"step": "checkState", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this can be kept as it is, onyl the unwrap-token and the expect message is different, right ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Correct. Added the check
bridged-tokens-wrapper/scenarios/remove_wrapped_token.scen.json
Outdated
Show resolved
Hide resolved
@@ -1090,7 +1096,7 @@ fn test_unwrap_token_create_transaction_should_work() { | |||
state | |||
.world | |||
.tx() | |||
.from(OWNER_ADDRESS) | |||
.from(MULTISIG_ADDRESS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how can a SC call another SC?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added an endpoint bridgedTokensWrapperDepositLiquidity
on multisig.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if a new endpoint was added, we should use it also in tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removed endpoint.
…fter-refund bridge-proxy: Clear storages after refund
bridge-proxy/src/bridge-proxy.rs
Outdated
|
||
if call_data.endpoint.is_empty() | ||
let non_empty_args = call_data.args.is_some(); | ||
if (call_data.endpoint.is_empty() && non_empty_args) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wrote an integration test for this. Apparently, if I send this RAW SC call data 000000000000000002faf08000
(empty function and 50 mil gas limit) it does not refund the transfer. Good catch @dragos-rebegea
eth_tx.tx_nonce, | ||
); | ||
// emit events only for non-SC destinations | ||
if self.blockchain().is_smart_contract(ð_tx.to) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To solve what @dragos-rebegea mentioned and fix the audit finding #9, do you think it would be better to do the following:
- emit the event only if the destination address is not a SC
- remove the
transfer_performed_sc_event
and instead emit thetransfer_performed_event
in the bridge proxy if the call to the SC succeeded
multi_transfer_esdt_proxy, | ||
}; | ||
|
||
const MAX_BOARD_MEMBERS: usize = 40; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why 40? I would go to a higher value like 100 or something
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a fix for issue 4 from the Audit document.
We iterate over all board signatures and the call may run out of gas.
Maybe an integration test from your side could help us adjust this value.
multisig/src/setup.rs
Outdated
|
||
#[only_owner] | ||
#[payable("*")] | ||
#[endpoint(bridgedTokensWrapperDepositLiquidity)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this? The owner of the wrapper is not the multisig contract
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed.
multisig/src/lib.rs
Outdated
|
||
let action_ids_mapper = self.batch_id_to_action_id_mapping(eth_batch_id); | ||
|
||
for act_id in action_ids_mapper.values() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should take max values here also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
transaction_details.refund_info.initial_nonce, | ||
); | ||
} | ||
let transaction_details = self.create_transaction_common(to, OptionalValue::None); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
require call from bridge proxy
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added + unit test.
Reference PR: multiversx/mx-bridge-eth-go#389